home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / advbas26.arc / ADVBAS.DOC next >
Encoding:
Text File  |  1986-09-19  |  54.3 KB  |  2,509 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                            ADVBAS.LIB v2.6, 9/19/86
  10.  
  11.  
  12.                Advanced Function Library for the BASIC Compiler
  13.  
  14.  
  15.                   Copyright (C) Thomas Hanlin III, 1985, 1986
  16.  
  17.  
  18.  
  19.  
  20.  
  21. Requirements:
  22.  
  23.  
  24.      An  IBM  PC  or  compatible  with  the IBM BASIC Compiler or the Microsoft
  25.  
  26. QuickBASIC Compiler.  PC-DOS/MS-DOS versions 2.0 or higher should be used.
  27.  
  28.  
  29.      The  BASIC  Compiler  is  a  powerful and flexible tool.  However, it suf-
  30.  
  31. fers  from  a  number of serious limitations.  The early versions were designed
  32.  
  33. for  DOS  v1,  and  cannot  handle version 2+ functions such as subdirectories;
  34.  
  35. there  is  little direct access to many advanced DOS features such as selective
  36.  
  37. screen  scrolling;  and  the  speed  is  not  all that it might be, for all its
  38.  
  39. improvement  over  interpreted  BASIC.  To reduce these problems, I've designed
  40.  
  41. a  number  of  assembly  language  routines  which perform desirable functions,
  42.  
  43. and  put  them  in a library which the compiler can access.  Since I have found
  44.  
  45. these  functions  to  be  useful,  I  thought I'd pass them on to other people.
  46.  
  47. You  may  use  ADVBAS functions in any of your programs.  If you do so, I would
  48.  
  49. appreciate  you  sending  a  contribution  (recommended  amount $25, which will
  50.  
  51. get  you  a  disk  containing the source code to these routines, an explanation
  52.  
  53. of  how  BASIC  tokenizes  programs, a crossreference utility, a communications
  54.  
  55. program  [Eterm]  with  source,  and  lots  more;  registered users may receive
  56.  
  57. updates  for  $10).   It  would  also  be nice if you acknowledged use of these
  58.  
  59. routines  in  your  program.   ADVBAS  may  be copied and distributed freely as
  60.  
  61. long  as  it  and this manual are included unchanged.  The copyright is to pre-
  62.  
  63. serve  my  options,  and  to  protect  you  from  the untoward modifications of
  64.  
  65. others.  It is not intended to prevent the free distribution of ADVBAS.
  66.  
  67.  
  68.      To  use  ADVBAS  functions,  you must copy ADVBAS.LIB to the disk on which
  69.  
  70. you  keep  your BASIC Compiler library files.  When you compile a program which
  71.  
  72. uses  an  ADVBAS function, you must specify ADVBAS (preceeded by a drive letter
  73.  
  74. if  it's  on a different disk than the program you're compiling) when LINK asks
  75.  
  76. you which libraries to use.  That is, at the LINKer prompt "Libraries [.LIB]:"
  77.  
  78. you should say "ADVBAS" (without the quotes!).
  79.  
  80.  
  81.      These  functions  have  not  caused  me any problems, and seem to be fully
  82.  
  83. debugged;  however,  I  will  not be responsible for any damages caused by use,
  84.  
  85. misuse,  or  inability to use ADVBAS.  But I'll try my best to fix any problems
  86.  
  87. you  may  turn  up!  Keep in mind that ADVBAS functions will work only with the
  88.  
  89. compiler, not the interpreter.
  90.  
  91.  
  92. Aside from their convenience, these functions:
  93.  
  94.  
  95.      1) add abilities which are not otherwise available;
  96.  
  97.      2) are generally faster than the corresponding Compiled BASIC code;
  98.  
  99.      3) usually take up less space in the resulting EXEcutable file;
  100.  
  101.      4) often leave you more free programming space.
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.                                 Operation Notes
  117.  
  118.  
  119.  
  120.  
  121.  
  122. Function Requirements:
  123.  
  124.  
  125.      Numeric variables used in function calls must be integers unless specified
  126.  
  127. otherwise.   Either  declare  them  using  DEFINT, or add a percent sign "%" to
  128.  
  129. the  end  of the variable name.  Strings sometimes must be defined to a certain
  130.  
  131. minimum  length,  due  to  limitations  on  what  machine language routines are
  132.  
  133. allowed  to  do  to  strings.   Follow the guidelines for each routine in these
  134.  
  135. respects, or the program will not work as expected!
  136.  
  137.  
  138.  
  139. Compatibility:
  140.  
  141.  
  142.      These  functions  vary  in  what  they  demand of your PC.  Some functions
  143.  
  144. will  work  only  on IBM PCs or clones, some will work on compatibles, and some
  145.  
  146. will  work  on  any  MS-DOS  routine.  The compatibility level of each function
  147.  
  148. is  now  listed,  using the categories CLONE (will work on hardware compatibles
  149.  
  150. only),  BIOS  (close  compatibles), DOS (any MS-DOS machine), and ANY (hardware
  151.  
  152. independent).  Be warned that the BASIC Compiler itself does not produce parti-
  153.  
  154. cularly  compatible  code  (BASIC  video  routines  seem to be BIOS-compatible,
  155.  
  156. etc).
  157.  
  158.  
  159. QuickBASIC 2.0:
  160.  
  161.  
  162.      You  can't  use  ADVBAS  (or any assembly-language routines) with QB2 when
  163.  
  164. the  compile-to-memory  option is on.  To use ADVBAS, either compile your prog-
  165.  
  166. rams  using  the  old  "separate  compilation method" (QB manual, page 538), or
  167.  
  168. set  the  compiler  to  either "Compile to .OBJ module" option.  You can get to
  169.  
  170. the latter from the QB environment by typing ALT-R, then choosing the
  171.  
  172. "Compile..."  option,  then  picking  the "Compile to .OBJ module" option.  See
  173.  
  174. your  QB  reference if you can't figure out how to do this-- for an "intuitive"
  175.  
  176. environment, the new setup is awfully counterintuitive.
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.      Please  mail  contributions,  suggestions  for additional functions, ques-
  186.  
  187. tions, comments, etc. to the following address:
  188.  
  189.  
  190.                                Thomas Hanlin III
  191.  
  192.                              6812 Sydenstricker Rd
  193.  
  194.                              Springfield, VA 22152
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.                                Routine Reference
  214.  
  215.  
  216.  
  217.  
  218.  
  219. Disk:
  220.  
  221.      DelSub, GetSub, MakeSub, SetSub:  subdirectory handling
  222.  
  223.      GetDrv, SetDrv:  default drive control
  224.  
  225.      DrvSpace:  space left on a given drive
  226.  
  227.      GetFdate, GetFtime, SetFTD, GetFattr, SetFattr:  file info control
  228.  
  229.      FindFirstF, FindNextF:  read file directory
  230.  
  231.      GetNameF, GetDateF, GetTimeF, GetAttrF, GetSizeF: file dir control
  232.  
  233.  
  234. Keyboard:
  235.  
  236.      GetKey: get one of a list of valid keys
  237.  
  238.      KeyPress: see if a key has been pressed
  239.  
  240.  
  241. String:
  242.  
  243.      Bsq, BusqLen, Busq:  text compression/decompression
  244.  
  245.      Locase, Upcase:  case conversion
  246.  
  247.      MultiAnd, MultiOr, MultiXor:  bit manipulations on chars in a string
  248.  
  249.      Strip, StripRange:  deletion of certain chars from a string
  250.  
  251.      LRotate, RRotate, Reverse:  reorder chars in a string
  252.  
  253.      Xlate:  run the chars of a string through a translation table
  254.  
  255.      Extract:  extract delimited substrings from a string using an index
  256.  
  257.      Soundex:  return the Soundex code of a string
  258.  
  259.      Checksum, CRC:  error checking (for telecom and other uses)
  260.  
  261.  
  262. Array:
  263.  
  264.      AddMatI, SetMatI:  integer array manipulation
  265.  
  266.      ReadBitF, WriteBitF:  handle arrays of arbitrary bit length
  267.  
  268.  
  269. Video:
  270.  
  271.      DMprint, Mprint, MprintC, Qprint, XQprint:  various print routines
  272.  
  273.      ClrEol, BkSpace, DelChr, InsChr, MDelChr, MInsChr:  screen control
  274.  
  275.      Mwindow, Scroll, BkScroll:  window control
  276.  
  277.      ScrSave, ScrRest, GetLine:  save/restore the contents of a screen
  278.  
  279.      ScrSaveP, ScrSavePD, ScrRestP, ScrRestPD:  variants on the above
  280.  
  281.      ReColor: change any screen color to another w/o clearing screen
  282.  
  283.  
  284. Miscellaneous:
  285.  
  286.      Any2Dec, Dec2Any:  radix conversion (decimal <--> another base)
  287.  
  288.      GetDOSv:  get the version number of the MS-DOS being used
  289.  
  290.      SetComm:  set up any comm port to any baud, without closing communications
  291.  
  292.      WeekDay:  returns the day of the week, Sunday through Saturday
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.                               Compatibility Chart
  316.  
  317.  
  318.  
  319.  
  320.  
  321. Works on ANY machine:
  322.  
  323.  
  324.      ADDMATI,  ANY2DEC,  BSQ,  BUSQ,  BUSQLEN, CHECKSUM, CRC, DEC2ANY, EXTRACT,
  325.  
  326. GETLINE,  LOCASE,  LROTATE,  MULTIAND,  MULTIOR,  MULTIXOR,  READBITF, REVERSE,
  327.  
  328. RROTATE, SETMATI, SOUNDEX, STRIP, STRIPRANGE, UPCASE, WRITEBITF, XLATE
  329.  
  330.  
  331.  
  332.  
  333. Works on DOS compatibles:
  334.  
  335.  
  336.      DELSUB,  DMPRINT,  DRVSPACE,  FINDFIRSTF,  FINDNEXTF,  GETATTRF, GETDATEF,
  337.  
  338. GETDOSV,  GETDRV,  GETFATTR,  GETFDATE,  GETFTIME,  GETNAMEF, GETSIZEF, GETSUB,
  339.  
  340. GETTIMEF, MAKESUB, SETDRV, SETFATTR, SETFTD, SETSUB, WEEKDAY
  341.  
  342.  
  343.  
  344.  
  345. Works on BIOS compatibles:
  346.  
  347.  
  348.      BKSCROLL,  BKSPACE,  CLREOL,  GETKEY,  KEYPRESS, MDELCHR, MINSCHR, MPRINT,
  349.  
  350. MPRINTC, MWINDOW, SCROLL, XMPRINT
  351.  
  352.  
  353.  
  354.  
  355. Works on CLONEs (hardware compatibles):
  356.  
  357.  
  358.      DELCHR,  INSCHR,  QPRINT,  RECOLOR, SCRREST, SCRRESTP, SCRRESTPD, SCRSAVE,
  359.  
  360. SCRSAVEP, SCRSAVEPD, SETCOMM, XQPRINT, XQPRINTD
  361.  
  362.  
  363.  
  364.  
  365.      Note  that  routines from higher sections will work on machines from lower
  366.  
  367. sections  (DOS-level  routines  will  work  on BIOS- and CLONE-level machines).
  368.  
  369. It  doesn't  work  the  other  way around (CLONE-level routines may not work on
  370.  
  371. a DOS-level machine).
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. Name: ADDMATI
  401.  
  402.  
  403. Type: Miscellaneous / ANY
  404.  
  405.  
  406. Description:
  407.  
  408.      Adds a scalar (integer) value to the first SIZ elements of an
  409.  
  410. integer  array.   You can subtract by adding a negative number.  If the results
  411.  
  412. of the calculation ever go outside integer range (-32768 to 32767), the
  413.  
  414. overflow flag is set on return.  See SETMATI for more information.
  415.  
  416.  
  417. Example:
  418.  
  419.      DEFINT A-Z: OPTION BASE 1: DIM ACK(10000): SIZ=10000
  420.  
  421.       .
  422.  
  423.       .
  424.  
  425.      ADDVAL=-6: ARLOC=VARPTR(ACK(1))
  426.  
  427.      CALL ADDMATI(ARLOC,SIZ,ADDVAL,OVFLOW)
  428.  
  429.      IF OVFLOW THEN PRINT"Uh oh, overflowed somewhere..."
  430.  
  431.      REM  we just subtracted six from each element of the array ACK.
  432.  
  433.  
  434.  
  435.  
  436.  
  437. Name: ANY2DEC
  438.  
  439.  
  440. Type: Miscellaneous / ANY
  441.  
  442.  
  443. Description:
  444.  
  445.      Converts  a  number  (in  string  form)  from any base (2-35) to a decimal
  446.  
  447. integer  (base 10).  The number to be converted may be in either signed integer
  448.  
  449. range  (-32768  to  32767)  or unsigned integer range (0 to 65535).  It is con-
  450.  
  451. verted to a signed integer, which is the only integer type BASIC supports.
  452.  
  453.  
  454. Example:
  455.  
  456.      INPUT"Number, base of number";ANUM$,NBASE
  457.  
  458.      CALL ANY2DEC(ANUM$,NBASE,DNUM,ERCD)
  459.  
  460.      IF ERCD THEN PRINT"Bad number!" ELSE PRINT"Decimal: ";DNUM
  461.  
  462.  
  463.  
  464.  
  465.  
  466. Name: BKSCROLL
  467.  
  468.  
  469. Type: Video / BIOS
  470.  
  471.  
  472. Description:
  473.  
  474.      The  same  as  SCROLL  (q.v.), but scrolls lines in the opposite direction
  475.  
  476. (Back Scroll).
  477.  
  478.  
  479. Example:
  480.  
  481.      CALL BKSCROLL(LEFTCOL,TOPROW,RTCOL,BOTROW,NUMLINES)
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499. Name: BKSPACE
  500.  
  501.  
  502. Type: Video / BIOS
  503.  
  504.  
  505. Description:
  506.  
  507.      Move  cursor  back  one space, destroying the character on the space moved
  508.  
  509. to.   Will  wrap  from one line to the next higher if necessary.  If at the top
  510.  
  511. left  corner  of  the screen, no action is performed.  Two arguments return the
  512.  
  513. new  cursor coordinates, since machine language programs cannot directly change
  514.  
  515. the BASIC cursor position.
  516.  
  517.  
  518. Example:
  519.  
  520.      CALL BKSPACE(COL,ROW) : LOCATE ROW,COL
  521.  
  522.  
  523.  
  524.  
  525.  
  526. Name: BSQ
  527.  
  528.  
  529. Type: String / ANY
  530.  
  531.  
  532. Description:
  533.  
  534.      Uses  several  techniques to compress blank spaces out of an ASCII string.
  535.  
  536. Savings  range  from 16% (reliable, for ordinary text) to up around 50% or more
  537.  
  538. for space-intensive info, such as lines in an assembly source file.  BSQ cannot
  539.  
  540. handle  more  than 127 spaces in a row on a single line, or lines which contain
  541.  
  542. ASCII   characters   greater   than   127   (which  are  IBM-specific  graphics
  543.  
  544. characters).   Do  not  use  BSQ  on  lines which may contain such information!
  545.  
  546. BSQ  compression  is  designed to produce printable (if odd-looking) text which
  547.  
  548. you may read/write to ordinary sequential files.
  549.  
  550.  
  551. Example:
  552.  
  553.      INPUT"String to squeeze";ST$: CALL BSQ(ST$,SLEN)
  554.  
  555.      PRINT"Squeezed string: ";LEFT$(ST$,SLEN)
  556.  
  557.  
  558.  
  559.  
  560.  
  561. Name: BUSQ
  562.  
  563.  
  564. Type: String / ANY
  565.  
  566.  
  567. Description:
  568.  
  569.      Decompresses  a  line  squeezed  by  BSQ.  Use BUSQLEN before this routine
  570.  
  571. to find out how long the unsqueezed line will be!
  572.  
  573.  
  574. Example:
  575.  
  576.      see BUSQLEN
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596. Name: BUSQLEN
  597.  
  598.  
  599. Type: String / ANY
  600.  
  601.  
  602. Description:
  603.  
  604.      Tells  how  long  a  line  squeezed with BSQ will be once it's unsqueezed.
  605.  
  606. You must use this before unsqueezing the line with BUSQ.
  607.  
  608.  
  609. Example:
  610.  
  611.      CALL BUSQLEN(ST$,SLEN)
  612.  
  613.      IF SLEN<0 THEN line is not squeezed, or got damaged somehow-- exit!
  614.  
  615.      ELSE UNSQ$=SPACE$(SLEN): CALL BUSQ(ST$,UNSQ$)
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671. Name: CHECKSUM
  672.  
  673.  
  674. Type: Miscellaneous / ANY
  675.  
  676.  
  677. Description:
  678.  
  679.      Calculates a checksum for a record.  Can be used with Xmodem or Ymodem.
  680.  
  681.  
  682. Example:
  683.  
  684.      CALL CHECKSUM(REC$,CHKSM)
  685.  
  686.  
  687.  
  688.  
  689.  
  690. Name: CLREOL
  691.  
  692.  
  693. Type: Video / BIOS
  694.  
  695.  
  696. Description:
  697.  
  698.      Clear  from  cursor  position  to  end  of line.  Doesn't move the cursor.
  699.  
  700. No arguments.
  701.  
  702.  
  703. Example:
  704.  
  705.      CALL CLREOL
  706.  
  707.  
  708.  
  709.  
  710.  
  711. Name: CRC
  712.  
  713.  
  714. Type: Miscellaneous / ANY
  715.  
  716.  
  717. Description:
  718.  
  719.      Calculates  a  cyclical  redundancy check value for a record.  Can be used
  720.  
  721. with Xmodem CRC or Ymodem CRC.
  722.  
  723.  
  724. Example:
  725.  
  726.   Sending a record:
  727.  
  728.      REC$=REC$+STRING$(2,0) : CALL CRC(REC$,HICRC,LOCRC) :
  729.  
  730.      MID$(REC$,LEN(REC$)-1,2) = CHR$(HICRC)+CHR$(LOCRC) : send Xmodem record
  731.  
  732.   Receiving a record:
  733.  
  734.      CALL CRC(REC$,HICRC,LOCRC) : IF HICRC=0 AND LOCRC=0
  735.  
  736.           THEN record is fine, save it
  737.  
  738.           ELSE record is bad, request it to be sent again
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763. Name: DEC2ANY
  764.  
  765.  
  766. Type: Miscellaneous / ANY
  767.  
  768.  
  769. Description:
  770.  
  771.      Converts  a  number  from decimal (base 10) to any other base (2-35).  The
  772.  
  773. number  will  be  converted  to  an unsigned integer (signed range of -32768 to
  774.  
  775. 32767  is  converted  to  unsigned  range  of  0 to 65535), to conform with the
  776.  
  777. built-in  BASIC  conversion functions HEX$ and OCT$.  ANUM$ must be initialized
  778.  
  779. to  the maximum size you expect the resultant number to be; this is recommended
  780.  
  781. to  be  16  characters,  which  is  the maximum length possible.  The result is
  782.  
  783. right-justified  in  the  field  you  provide,  so  if you want to keep leading
  784.  
  785. zeroes, just ignore the actual-length specification ALEN.
  786.  
  787.  
  788. Example:
  789.  
  790.      INPUT"Decimal number, to base";DNUM,NBASE
  791.  
  792.      ANUM$ = STRING$(16,"0"): CALL DEC2ANY(DNUM,NBASE,ANUM$,ALEN)
  793.  
  794.      IF ALEN<0 THEN PRINT"Bad base or ANUM$ initialized too short"
  795.  
  796.      ELSE PRINT"Result: ";RIGHT$(ANUM$,ALEN)
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845. Name: DELCHR
  846.  
  847.  
  848. Type: Video / CLONE
  849.  
  850.  
  851. Description:
  852.  
  853.      Deletes  a character from the specified location on the screen.  The char-
  854.  
  855. acter  at  that  location  will  disappear,  and all characters to the right of
  856.  
  857. it  on  the  same  screen  line  will be shifted left one space.  This function
  858.  
  859. should  work  on either color or monochrome monitors, in either 40 or 80 column
  860.  
  861. text  modes.   The  first  page only (color monitor) is supported, and graphics
  862.  
  863. modes won't work.
  864.  
  865.  
  866. Example:
  867.  
  868.      COL = POS(0): ROW = CSRLIN: CALL DELCHR(ROW,COL)
  869.  
  870.  
  871.  
  872.  
  873.  
  874. Name: DELSUB
  875.  
  876.  
  877. Type: Disk / DOS
  878.  
  879.  
  880. Description:
  881.  
  882.      Deletes  a  subdirectory.   Parameters  used  are  the  same as in SETSUB.
  883.  
  884. Note  that  you  may  not delete a subdirectory if it has any files left in it,
  885.  
  886. or if it is the main directory, or if it is the current default subdirectory.
  887.  
  888.  
  889. Example:
  890.  
  891.      TMP$ = SUB$+CHR$(0): CALL DELSUB(TMP$,ERRCODE)
  892.  
  893.      IF ERRCODE THEN couldn't delete subdir ELSE subdir deleted
  894.  
  895.  
  896.  
  897.  
  898.  
  899. Name: DMPRINT
  900.  
  901.  
  902. Type: Video / DOS
  903.  
  904.  
  905. Description:
  906.  
  907.      Displays  a  string  at  the  current cursor position, using DOS calls for
  908.  
  909. output (so device drivers such as ANSI.SYS will work).  This routine is consid-
  910.  
  911. erably faster than MPRINT (q.v.), but offers fewer amenities.  Character trans-
  912.  
  913. lation  is  limited to what DOS provides, meaning that, for instance, Backspace
  914.  
  915. just  moves  the  cursor back without wiping out the previous character.  Other
  916.  
  917. control  codes may not be translated as you might hope, either.  Finally, since
  918.  
  919. DOS  provides  no way of finding the current print position, you have to figure
  920.  
  921. out  where  the cursor will be yourself if you need it (like other display rou-
  922.  
  923. tines,  DMPRINT  does not update the BASIC cursor position).  You can gain con-
  924.  
  925. trol  of  such  things  by  using the ANSI.SYS driver.  See your DOS manual for
  926.  
  927. more information on that.
  928.  
  929.  
  930. Example:
  931.  
  932.      CALL DMPRINT(ST$)
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947. Name: DRVSPACE
  948.  
  949.  
  950. Type: Disk / DOS
  951.  
  952.  
  953. Description:
  954.  
  955.      Returns  the  amount  of free space left on a given disk drive.  The drive
  956.  
  957. string  may  be  any  legal disk drive, or "@" (AT sign) for the default drive,
  958.  
  959. and  must  be  at  least  one  character long.  An illegal drive or other error
  960.  
  961. will cause free space to be returned as a negative value.
  962.  
  963.  
  964. Example:
  965.  
  966.      DRV$="A:"
  967.  
  968.       .
  969.  
  970.       .
  971.  
  972.      CALL DRVSPACE(DRV$,A,B,C): FREE# = CDBL(A)*CDBL(B)*CDBL(C)
  973.  
  974.      PRINT"Free space on drive ";DRV$;" is";FREE#;"bytes."
  975.  
  976.  
  977.  
  978.  
  979.  
  980. Name: EXTRACT
  981.  
  982.  
  983. Type: String / ANY
  984.  
  985.  
  986. Description:
  987.  
  988.      Extracts  a  delimited  substring  from a string given an index.  Requires
  989.  
  990. a  string  of  any  length,  a  delimiter of length one character, and an index
  991.  
  992. value  from  1-256;  returns the starting location and length of the substring.
  993.  
  994. If  the  delimiter  is  null  (an error), the substring length will be returned
  995.  
  996. as  -1.  If the index value is greater than the number of delimited substrings,
  997.  
  998. a null substring will be returned.
  999.  
  1000.  
  1001. Example:
  1002.  
  1003.      ST$="John Doe/15 Maple Rd/Hometown, CA 99199/(300) 111-1111"
  1004.  
  1005.      INDEX=2: DELIMITER$="/": CALL EXTRACT(ST$,DELIMITER$,INDEX,START,SLEN)
  1006.  
  1007.      PRINT MID$(ST$,START,SLEN)
  1008.  
  1009.      REM  This will print the second substring (INDEX=2) of the string
  1010.  
  1011.      REM  (ST$) delimited by "/" (DELIMITER$), which in this case will
  1012.  
  1013.      REM  be "15 Maple Rd".
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042. Name: FINDFIRSTF
  1043.  
  1044.  
  1045. Type: Disk / DOS
  1046.  
  1047.  
  1048. Description:
  1049.  
  1050.      Given  a  filename  (which  may  contain  the wildcards "*" and "?", and a
  1051.  
  1052. drive  and  path  spec  if  you like), this searches the default (or specified)
  1053.  
  1054. directory  to  find  the  first matching file.  Further matches can be obtained
  1055.  
  1056. through  the  FINDNEXTF  routine (q.v.).  If there is a match, ERCD will return
  1057.  
  1058. zero,  otherwise  it  will  return  a positive value (unless you entered a null
  1059.  
  1060. filename,  in  which  case ERCD will be -1 to flag an error).  You can retrieve
  1061.  
  1062. various  information  about  the  matched  file  via  a number of supplementary
  1063.  
  1064. functions: GETNAMEF to get the filename, GETATTRF to get the attribute (there's
  1065.  
  1066. a  page  at the end of this document on file attributes), GETDATEF and GETTIMEF
  1067.  
  1068. to  get  the date and time, and GETSIZEF to get the file size.  You may specify
  1069.  
  1070. a  search  attribute as well: 0 (zero) to match normal files, 2 to match hidden
  1071.  
  1072. files,  4  for  system files, and 16 for subdirectories.  Attributes other than
  1073.  
  1074. zero  will return normal files as well as the specified type, and you can match
  1075.  
  1076. on  more  than  one kind of attribute (for instance, to get all kinds of files,
  1077.  
  1078. you'd  use an attribute of 22, or 2+4+16).  You can read the volume label using
  1079.  
  1080. an  attribute  of  8,  which  will  return only the volume label... supposedly.
  1081.  
  1082. In  actual  practice,  the  read-volume-label routine is not entirely reliable,
  1083.  
  1084. so  be  sure  to  check  the attribute of the matched file to make sure that it
  1085.  
  1086. is in fact 8.
  1087.  
  1088.  
  1089.      This  function  can  be  used  to  duplicate the DOS directory command, or
  1090.  
  1091. to allow filename wildcards in your program, among other things.
  1092.  
  1093.  
  1094. Example:
  1095.  
  1096.      FIL$=FIL$+CHR$(0): CALL FINDFIRSTF(FIL$,ATTR,ERCD)
  1097.  
  1098.      IF ERCD THEN PRINT"No matching files"
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135. Name: FINDNEXTF
  1136.  
  1137.  
  1138. Type: Disk / DOS
  1139.  
  1140.  
  1141. Description:
  1142.  
  1143.      This is used after the FINDFIRSTF function (q.v.) in order to find further
  1144.  
  1145. matching files.
  1146.  
  1147.  
  1148. Example:
  1149.  
  1150.      CALL FINDNEXTF(ERCD)
  1151.  
  1152.      IF ERCD THEN PRINT"No more matching files"
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158. Name: GETATTRF
  1159.  
  1160.  
  1161. Type: Disk / DOS
  1162.  
  1163.  
  1164. Description:
  1165.  
  1166.      Returns  the  actual  attribute  of  a  file  matched  using FINDFIRSTF or
  1167.  
  1168. FINDNEXTF.  See the end of this document for information on file attributes.
  1169.  
  1170.  
  1171. Example:
  1172.  
  1173.      REM  use this AFTER calling FINDFIRSTF / FINDNEXTF to initialize
  1174.  
  1175.      REM  the appropriate file information!
  1176.  
  1177.      CALL GETATTRF(ATTR)
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183. Name: GETDATEF
  1184.  
  1185.  
  1186. Type: Disk / DOS
  1187.  
  1188.  
  1189. Description:
  1190.  
  1191.      Returns  the  date  associated  with  the file matched using FINDFIRSTF or
  1192.  
  1193. FINDNEXTF.
  1194.  
  1195.  
  1196. Example:
  1197.  
  1198.      CALL GETDATEF(MONTH,DAY,YEAR)
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225. Name: GETDOSV
  1226.  
  1227.  
  1228. Type: Miscellaneous / DOS
  1229.  
  1230.  
  1231. Description:
  1232.  
  1233.      Gets  MS-DOS  version.   The  major version is returned in the first para-
  1234.  
  1235. meter,  the  minor  version  in  the  second (e.g., MS-DOS v. 2.11 would return
  1236.  
  1237. MAJ = 2, MIN = 11).
  1238.  
  1239.  
  1240. Example:
  1241.  
  1242.      CALL GETDOSV(MAJ,MIN)
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248. Name: GETDRV
  1249.  
  1250.  
  1251. Type: Disk / DOS
  1252.  
  1253.  
  1254. Description:
  1255.  
  1256.      Returns  the  letter  of  the  default drive.  The drive string must be at
  1257.  
  1258. least one character long.
  1259.  
  1260.  
  1261. Example:
  1262.  
  1263.      DRV$="x:" : CALL GETDRV(DRV$)
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269. Name: GETFATTR
  1270.  
  1271.  
  1272. Type: Disk / DOS
  1273.  
  1274.  
  1275. Description:
  1276.  
  1277.      Gets  file  attribute.   See section on file attributes at the end of this
  1278.  
  1279. manual.
  1280.  
  1281.  
  1282. Example:
  1283.  
  1284.      FIL$ = FIL$ + CHR$(0): CALL GETFATTR(FIL$,ATR)
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313. Name: GETFDATE
  1314.  
  1315.  
  1316. Type: Disk / DOS
  1317.  
  1318.  
  1319. Description:
  1320.  
  1321.      GETFDATE  returns  the  file  creation  date, that is, the date you see on
  1322.  
  1323. a  file  when  you  get  a DIRectory.  The file name must be terminated with an
  1324.  
  1325. ASCII  NUL  character.  If there is an error, such as there being no such file,
  1326.  
  1327. the month will be -1.
  1328.  
  1329.  
  1330. Example:
  1331.  
  1332.      FIL$ = "TESTFILE.TXT" + CHR$(0)
  1333.  
  1334.      CALL GETFDATE(FIL$,MONTH,DAY,YEAR)
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340. Name: GETFTIME
  1341.  
  1342.  
  1343. Type: Disk / DOS
  1344.  
  1345.  
  1346. Description:
  1347.  
  1348.      This  function  complements  GETFDATE, and returns the file creation time.
  1349.  
  1350. The  hour  is in 24-hour (military) format, and will be returned as -1 if there
  1351.  
  1352. is  no such file or a bad file name.  The seconds are rounded to the next lower
  1353.  
  1354. even  number,  due to the DOS storage format.  The file name must be terminated
  1355.  
  1356. with an ASCII zero, or NUL character.
  1357.  
  1358.  
  1359. Example:
  1360.  
  1361.      FIL$ = "ANYFILE.EXT" + CHR$(0)
  1362.  
  1363.      CALL GETFTIME(FIL$,HOUR,MINUTE,SECOND)
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400. Name: GETKEY
  1401.  
  1402.  
  1403. Type: Keyboard / BIOS
  1404.  
  1405.  
  1406. Description:
  1407.  
  1408.      Waits  until  one  of  a list of keys is pressed, and returns it.  The key
  1409.  
  1410. list  (any  length)  should  be uppercase, and if the length is null, the first
  1411.  
  1412. key  pressed  will  be  returned.   The  key returned will be capitalized.  The
  1413.  
  1414. variable  to return the key in must be at least one character long.  This func-
  1415.  
  1416. tion is designed for returning one of a menu of choices, for example.
  1417.  
  1418.  
  1419. Example:
  1420.  
  1421.      GOODKEYS$="KEY LIST"
  1422.  
  1423.              .
  1424.  
  1425.              .
  1426.  
  1427.      KY$="x": CALL GETKEY(GOODKEYS$,KY$)
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433. Name: GETLINE
  1434.  
  1435.  
  1436. Type: Video / ANY
  1437.  
  1438.  
  1439. Description:
  1440.  
  1441.      Returns a selected line from a screen saved via SCRSAVE, with the trailing
  1442.  
  1443. spaces removed.  The line string must be at least 80 characters long.
  1444.  
  1445.  
  1446. Example:
  1447.  
  1448.      DEFINT A-Z: OPTION BASE 1: DIM SCR(2000)
  1449.  
  1450.      WHERE=VARPTR(SCR(1)): CALL SCRSAVE(WHERE): CLS
  1451.  
  1452.      LINENR=10: LIN$=SPACE$(80): WHERE=VARPTR(SCR(1))
  1453.  
  1454.      CALL GETLINE(WHERE,LINENR,LIN$,LLEN)
  1455.  
  1456.      PRINT"Line 10 was:": PRINT LEFT$(LIN$,LLEN)
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462. Name: GETNAMEF
  1463.  
  1464.  
  1465. Type: Disk / DOS
  1466.  
  1467.  
  1468. Description:
  1469.  
  1470.      Returns  the  filename  of the file matched using FINDFIRSTF or FINDNEXTF.
  1471.  
  1472. The  FIL$  string  must  be  initialized  to  at least 12 characters in length.
  1473.  
  1474. The  actual  length  of  FIL$ will be returned in FLEN, which will be -1 if you
  1475.  
  1476. didn't  initialize  FIL$  long enough.  Note that the filename will not contain
  1477.  
  1478. a drive or path spec.
  1479.  
  1480.  
  1481. Example:
  1482.  
  1483.      FIL$ = SPACE$(12): CALL GETNAMEF(FIL$,FLEN): FIL$ = LEFT$(FIL$,FLEN)
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500. Name: GETSIZEF
  1501.  
  1502.  
  1503. Type: Disk / DOS
  1504.  
  1505.  
  1506. Description:
  1507.  
  1508.      Returns  the  size of the file matched via FINDFIRSTF or FINDNEXTF.  Since
  1509.  
  1510. the  file  size  may  be  outside integer bounds, there is some additional code
  1511.  
  1512. you  will  have  to  add  which uses double-precision values (see the example).
  1513.  
  1514. You  can  modify  the example to use single-precision instead, but really large
  1515.  
  1516. file sizes will then lapse into exponential notation.
  1517.  
  1518.  
  1519. Example:
  1520.  
  1521.      CALL GETSIZEF(SIZELOW,SIZEHIGH): SIZELOW# = CDBL(SIZELOW)
  1522.  
  1523.      IF SIZELOW < 0 THEN SIZELOW# = SIZELOW# + 65536#
  1524.  
  1525.      FILESIZE# = SIZELOW# + CDBL(SIZEHIGH) * 65536#
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531. Name: GETSUB
  1532.  
  1533.  
  1534. Type: Disk / DOS
  1535.  
  1536.  
  1537. Description:
  1538.  
  1539.      Gets the default subdirectory.  The subdirectory string must be 64 charac-
  1540.  
  1541. ters  long,  and  it  is  recommended  that you set it to ASCII zeroes (the NUL
  1542.  
  1543. character).  The length of the subdirectory string is returned as an integer
  1544.  
  1545. value.  Note that the string will NOT be started by a backslash "\" character--
  1546.  
  1547. you should add one if appropriate.
  1548.  
  1549.  
  1550. Example:
  1551.  
  1552.      SUB$ = STRING$(64,0) : CALL GETSUB(SUB$,SLEN) :
  1553.  
  1554.      SUB$ = "\" + LEFT$(SUB$,SLEN)
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560. Name: GETTIMEF
  1561.  
  1562.  
  1563. Type: Disk / DOS
  1564.  
  1565.  
  1566. Description:
  1567.  
  1568.      Returns  the  time  associated  with  the  file  matched  by FINDFIRSTF or
  1569.  
  1570. FINDNEXTF.  The hour is returned in military (24-hour) format.
  1571.  
  1572.  
  1573. Example:
  1574.  
  1575.      CALL GETTIMEF(HOUR,MINUTE,SECOND)
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596. Name: INSCHR
  1597.  
  1598.  
  1599. Type: Video / CLONE
  1600.  
  1601.  
  1602. Description:
  1603.  
  1604.      Inserts a space at the specified screen location.  The character previous-
  1605.  
  1606. ly  at  that  position and all characters to the right of it on the same screen
  1607.  
  1608. line  will  be  shifted  right  one  space.  Subject to the same limitations as
  1609.  
  1610. DELCHR (q.v.).
  1611.  
  1612.  
  1613. Example:
  1614.  
  1615.      COL = POS(0): ROW = CSRLIN: CALL INSCHR(ROW,COL): PRINT"*";
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621. Name: KEYPRESS
  1622.  
  1623.  
  1624. Type: Keyboard / BIOS
  1625.  
  1626.  
  1627. Description:
  1628.  
  1629.      Tells  you  whether  a key is waiting in the keyboard buffer (for use with
  1630.  
  1631. INKEY$ routines, etc).  KYHIT is set to -1 if a key is waiting, 0 otherwise.
  1632.  
  1633.  
  1634. Example:
  1635.  
  1636.      100 CALL KEYPRESS(KYHIT):IF KYHIT THEN KY$=INKEY$:GOTO 300 ELSE 100
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642. Name: LOCASE
  1643.  
  1644.  
  1645. Type: String / ANY
  1646.  
  1647.  
  1648. Description:
  1649.  
  1650.      Converts  a  string  to  all  lowercase.  Leaves non-alphabetic characters
  1651.  
  1652. untouched.  String may be any length.
  1653.  
  1654.  
  1655. Example:
  1656.  
  1657.      MSG$="THis IS a test OF tHe lowercase CONVERTER!"
  1658.  
  1659.                .
  1660.  
  1661.                .
  1662.  
  1663.      CALL LOCASE(MSG$)
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688. Name: LROTATE
  1689.  
  1690.  
  1691. Type: String / ANY
  1692.  
  1693.  
  1694. Description:
  1695.  
  1696.      Rotates  the characters in a string left.  That is, the leftmost character
  1697.  
  1698. is removed, and tacked onto the end of the string.  This is useful for rotating
  1699.  
  1700. queues  and  for  character-graphics animation.  If the string is of length one
  1701.  
  1702. or less, it is returned unchanged.
  1703.  
  1704.  
  1705. Example:
  1706.  
  1707.      ST$ = "12345": CALL LROTATE(ST$)
  1708.  
  1709.      REM  ST$ will end up being "23451"
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715. Name: MAKESUB
  1716.  
  1717.  
  1718. Type: Disk / DOS
  1719.  
  1720.  
  1721. Description:
  1722.  
  1723.      Makes a subdirectory.  Parameters used are the same as in SETSUB.
  1724.  
  1725.  
  1726. Example:
  1727.  
  1728.      TMP$ = SUB$+CHR$(0): CALL MAKESUB(TMP$,ERRCODE)
  1729.  
  1730.      IF ERRCODE THEN couldn't make subdir ELSE subdir created
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736. Name: MDELCHR
  1737.  
  1738.  
  1739. Type: Video / BIOS
  1740.  
  1741.  
  1742. Description:
  1743.  
  1744.      Deletes the character at the current cursor position.  It obeys the window
  1745.  
  1746. defined by MWINDOW.  It's more compatible than DELCHR, but much slower.
  1747.  
  1748.        Note  that  this  routine  can  be used to scroll a window left by doing
  1749.  
  1750. an MDELCHR at the first location of each line to be scrolled.  To scroll right,
  1751.  
  1752. do the same using MINSCHR instead.
  1753.  
  1754.  
  1755. Example:
  1756.  
  1757.      CALL MDELCHR
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781. Name: MINSCHR
  1782.  
  1783.  
  1784. Type: Video / BIOS
  1785.  
  1786.  
  1787. Description:
  1788.  
  1789.      Inserts a space at the current cursor position, obeying the window defined
  1790.  
  1791. by MWINDOW.  See notes at MDELCHR.
  1792.  
  1793.  
  1794. Example:
  1795.  
  1796.      CALL MINSCHR
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802. Name: MPRINTC
  1803.  
  1804.  
  1805. Type: Video / BIOS
  1806.  
  1807.  
  1808. Description:
  1809.  
  1810.      Using  this  function,  you  can  at  last  access  device drivers such as
  1811.  
  1812. ANSI.SYS.   This  is a video output function which goes through MS-DOS function
  1813.  
  1814. calls.   It  prints  a single character to the display.  Advantages: allows use
  1815.  
  1816. of   ANSI.SYS   and   similar   video   drivers,  and  windowing  via  MWINDOW.
  1817.  
  1818. Disadvantages: is slower and takes more memory that the usual PRINT statement.
  1819.  
  1820.  
  1821. Example:
  1822.  
  1823.      CALL MPRINTC(CH$,COL,ROW): LOCATE ROW,COL
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829. Name: MPRINT
  1830.  
  1831.  
  1832. Type: Video / BIOS
  1833.  
  1834.  
  1835. Description:
  1836.  
  1837.      Same  as  MPRINTC  (q.v.), only it allows you to send an entire string out
  1838.  
  1839. to the display, rather than just a single character.
  1840.  
  1841.  
  1842. Example:
  1843.  
  1844.      CALL MPRINT(ST$,COL,ROW): LOCATE ROW,COL
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871. Name: MULTIAND
  1872.  
  1873.  
  1874. Type: String / ANY
  1875.  
  1876.  
  1877. Description:
  1878.  
  1879.      This  is  a  flexible  function  with many possible uses.  Every character
  1880.  
  1881. in  a  given  string  is  ANDed  with a value you supply.  One thing this could
  1882.  
  1883. be  used  for is translating Wordstar files to ASCII files, by using a bit mask
  1884.  
  1885. (the  value  that  will  be ANDed with the character) of &H7F, which strips off
  1886.  
  1887. the  high  bit  of  each character.  The string may be any length; the bit mask
  1888.  
  1889. is an integer, with only the low byte in use (value of 0-255).
  1890.  
  1891.  
  1892. Example:
  1893.  
  1894.      ST$ = "" : FOR X=65 TO 70: ST$ = CHR$(X)+CHR$(X+128): NEXT : PRINT ST$
  1895.  
  1896.      BITMASK = &H7F : CALL MULTIAND(ST$,BITMASK) : PRINT ST$
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902. Name: MULTIOR
  1903.  
  1904.  
  1905. Type: String / ANY
  1906.  
  1907.  
  1908. Description:
  1909.  
  1910.      Does  the  exact  opposite  of  MULTIAND--  instead of stripping off bits,
  1911.  
  1912. it  turns  on  bits.   It ORs instead of ANDs.  One possible use for this would
  1913.  
  1914. be  to  encode  a  text  string by ORing with 128, and later decoding by ANDing
  1915.  
  1916. with  128.   This  would allow you to save the string to disk using text files,
  1917.  
  1918. even  if  the string included control codes.  It won't work right if the string
  1919.  
  1920. has  graphics  characters  (using ExtASCII codes, which are codes from 128-255)
  1921.  
  1922. in it, though.  The parameters are the same as for MULTIAND.
  1923.  
  1924.  
  1925. Example:
  1926.  
  1927.      ST$ = "ABCDE": PRINT ST$: SETBITS = &H80
  1928.  
  1929.      CALL MULTIOR(ST$,SETBITS): PRINT ST$
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935. Name: MULTIXOR
  1936.  
  1937.  
  1938. Type: String / ANY
  1939.  
  1940.  
  1941. Description:
  1942.  
  1943.      An  exclusive-or  operation  for  strings.  Bits in the string will be set
  1944.  
  1945. only  if they are set in the string byte or mask byte, but not in both of them.
  1946.  
  1947. Note  that  this  can  be used as a "MULTINOT" function by using a mask of &HFF
  1948.  
  1949. or  255.   In  this  case,  all  bits are set in the mask, so the result of the
  1950.  
  1951. XOR  will  be  the  same  as a NOT operation on the string.  Note that XORing a
  1952.  
  1953. string  with  the  same  value  twice  will return the original string-- it can
  1954.  
  1955. thus be used to encode and decode strings.
  1956.  
  1957.  
  1958. Example:
  1959.  
  1960.      CALL MULTIXOR(ST$,MASK)
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974. Name: MWINDOW
  1975.  
  1976.  
  1977. Type: Video / BIOS
  1978.  
  1979.  
  1980. Description:
  1981.  
  1982.      Sets up a window for the MPRINT and MPRINTC routines.  Windows are defined
  1983.  
  1984. by  their  upper  left  corner  and  lower right corner.  The default window is
  1985.  
  1986. thus  (0,0,80,24),  which  leaves  out  the  bottom line (BASIC's status line).
  1987.  
  1988. To  use  the full screen, call this routine with values (0,0,80,25).  Note that
  1989.  
  1990. the cursor should be positioned inside the window before using MPRINT/MPRINTC.
  1991.  
  1992. Note also that windows should be defined to contain at least two rows.
  1993.  
  1994.  
  1995. Example:
  1996.  
  1997.      LFTCOL = 20: TOPROW = 5: RTCOL = 60: BOTROW = 15
  1998.  
  1999.      CALL MWINDOW(LFTCOL,TOPROW,RTCOL,BOTROW): LOCATE TOPROW,LFTCOL
  2000.  
  2001.      REM  sets up a window in the middle of the screen
  2002.  
  2003.      REM  of 40 cols by 10 rows.
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009. Name: QPRINT
  2010.  
  2011.  
  2012. Type: Video / CLONE
  2013.  
  2014.  
  2015. Description:
  2016.  
  2017.      This  function  bypasses  the  usual  video  routines, and prints a string
  2018.  
  2019. directly  on  the screen, at a -much- higher speed than the normal PRINT state-
  2020.  
  2021. ment  does.   It  also contains a built-in LOCATE statement, and doesn't affect
  2022.  
  2023. the  cursor  position.   The string may be any length.  Control characters will
  2024.  
  2025. show  up  as  graphics  characters  instead of having their original functions,
  2026.  
  2027. and  the  color/attributes  used  will be the ones already on the screen.  This
  2028.  
  2029. works  for  40  or  80 column displays, monochrome or color.  Display page zero
  2030.  
  2031. will be used (if applicable).
  2032.  
  2033.      Note:  this  function  appeared  in BYTE magazine in a different form, and
  2034.  
  2035. has  been  modified  several  times  since.  It is not solely my creation.  See
  2036.  
  2037. the source code for further information.
  2038.  
  2039.  
  2040. Example:
  2041.  
  2042.      ST$ = "This is a test of fast screen printing"
  2043.  
  2044.      ROW = 10: COL = 20
  2045.  
  2046.      CALL QPRINT(ST$,ROW,COL)
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072. Name: READBITF
  2073.  
  2074.  
  2075. Type: Miscellaneous / ANY
  2076.  
  2077.  
  2078. Description:
  2079.  
  2080.      Reads  a  word  from  an  array  of  arbitrary bit length, given an index.
  2081.  
  2082. The  words  in  the  array  may be made of one to eight bits.  Indices begin at
  2083.  
  2084. zero and are limited by integer range.  That is up to &HFFFF, subject to memory
  2085.  
  2086. constraints--  the  index is taken to be an unsigned integer value.  This func-
  2087.  
  2088. tion  allows  very memory-efficient storage of arrays of numbers, provided that
  2089.  
  2090. the  numbers are within a restricted range.  The simulated array is held within
  2091.  
  2092. a  normal  integer  array,  which  must be dimensioned large enough to hold all
  2093.  
  2094. of  the  arbitrary-length  words  (will  depend  on bits per word and number of
  2095.  
  2096. words desired).
  2097.  
  2098.  
  2099. Example:
  2100.  
  2101.      OPTION BASE 0: DEFINT A-Z: DIM INTARRAY(50): BITFSIZE=8
  2102.  
  2103.        .
  2104.  
  2105.        .
  2106.  
  2107.      ARRAYLOC=VARPTR(INTARRAY(0))
  2108.  
  2109.      CALL READBITF(ARRAYLOC,NDX,BITFSIZE,VALUE)
  2110.  
  2111.      REM  Returns a value from the array location indexed by NDX,
  2112.  
  2113.      REM  where the array is composed of bytes (8-bit words).
  2114.  
  2115.      REM  See the disk file BITFTEST.BAS in the \SOURCE subdirectory
  2116.  
  2117.      REM  for a working example program (compiled BASIC only!!!)
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123. Name: RECOLOR
  2124.  
  2125.  
  2126. Type: Video / CLONE
  2127.  
  2128.  
  2129. Description:
  2130.  
  2131.      Takes  everything  on  the  screen that's of a given color and changes its
  2132.  
  2133. color  to  whatever  you  like.   This can be used for special effects, or just
  2134.  
  2135. to  change  the  screen  color  without  having to clear the screen.  This will
  2136.  
  2137. work on either mono or color monitors, in text modes only.  The color attribute
  2138.  
  2139. must  be  defined  from  the foreground and background colors using the formula
  2140.  
  2141. shown below.
  2142.  
  2143.  
  2144. Example:
  2145.  
  2146.      OLDCOLR = (BGNDCOLR AND 7)*16 + FGNDCOLR
  2147.  
  2148.      NEWCOLR = (NEWBGNDCOLR AND 7)*16 + NEWFGNDCOLR
  2149.  
  2150.      CALL RECOLOR(OLDCOLR,NEWCOLR)
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173. Name: REVERSE
  2174.  
  2175.  
  2176. Type: String / ANY
  2177.  
  2178.  
  2179. Description:
  2180.  
  2181.      Reverses  the  order of characters in a string.  This can be combined with
  2182.  
  2183. the  XLATE  function  and  a  judiciously-designed translation table to provide
  2184.  
  2185. mirror images of strings for character-graphics-based displays.
  2186.  
  2187.  
  2188. Example:
  2189.  
  2190.      MSG$="This is a test": CALL REVERSE(MSG$): PRINT MSG$
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196. Name: RROTATE
  2197.  
  2198.  
  2199. Type: String / ANY
  2200.  
  2201.  
  2202. Description:
  2203.  
  2204.      Rotates  the  characters  in a string right.  This is the same as LROTATE,
  2205.  
  2206. only in reverse.  See LROTATE for further details.
  2207.  
  2208.  
  2209. Example:
  2210.  
  2211.      ST$ = "12345": CALL RROTATE(ST$)
  2212.  
  2213.      REM  ST$ will end up being "51234"
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219. Name: SCROLL
  2220.  
  2221.  
  2222. Type: Video / BIOS
  2223.  
  2224.  
  2225. Description:
  2226.  
  2227.      Scrolls any selected portion of the screen as many times as you like
  2228.  
  2229. (1-255,  or  use  0 to clear that part of the screen entirely).  Five arguments
  2230.  
  2231. give  coordinates  (LEFTCOL,TOPROW)  of  the  upper  left corner of the area to
  2232.  
  2233. be  scrolled,  coordinates (RTCOL,BOTROW) of the lower right corner of the area
  2234.  
  2235. to  be  scrolled,  and  the  number  of times to scroll the area.  This routine
  2236.  
  2237. may  be  used  to create windows.  Note that RTCOL must be at least one greater
  2238.  
  2239. than  LEFTCOL  (no  single-line  scrolling,  obviously).   Parameters  are  not
  2240.  
  2241. checked, so be careful not to use illegal screen coordinates.
  2242.  
  2243.  
  2244. Example:
  2245.  
  2246.      CALL SCROLL(LEFTCOL,TOPROW,RTCOL,BOTROW,NUMLINES)
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268. Name: SCRREST
  2269.  
  2270.  
  2271. Type: Video / CLONE
  2272.  
  2273.  
  2274. Description:
  2275.  
  2276.      Restores  the  screen  display from an image put into an array by SCRSAVE.
  2277.  
  2278. Same requirements and limitations of SCRSAVE.
  2279.  
  2280.  
  2281. Example:
  2282.  
  2283.      WHERE = VARPTR(SCR(1)): CALL SCRREST(WHERE): LOCATE OLDROW,OLDCOL
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289. Name: SCRSAVE
  2290.  
  2291.  
  2292. Type: Video / CLONE
  2293.  
  2294.  
  2295. Description:
  2296.  
  2297.      Stores  the  current screen display (page 0 only) in an array.  Text modes
  2298.  
  2299. only.   Requires  an  array  of  4000 bytes, and an integer which points to the
  2300.  
  2301. location of the array.  The cursor position is not saved.
  2302.  
  2303.  
  2304. Example:
  2305.  
  2306.      DEFINT A-Z: OPTION BASE 1: DIM SCR(2000)
  2307.  
  2308.       .
  2309.  
  2310.       .
  2311.  
  2312.      WHERE = VARPTR(SCR(1)): CALL SCRSAVE(WHERE)
  2313.  
  2314.      OLDCOL = POS(0) : OLDROW = CSRLIN
  2315.  
  2316.      REM  Dim of 2000 w/ option base 1 gives us 2000 integers, each of
  2317.  
  2318.      REM  which occupy two bytes, giving 4000 bytes of storage space.
  2319.  
  2320.      REM  Note: you can store more than one screen in an array by
  2321.  
  2322.      REM  dimensioning it large enough.  Use WHERE=VARPTR(SCR(2001))
  2323.  
  2324.      REM  to locate the second screen, and so forth.
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330. Name: SCRRESTP, SCRRESTPD, SCRSAVEP, SCRSAVEPD
  2331.  
  2332.  
  2333. Type: Video / CLONE
  2334.  
  2335.  
  2336. Description:
  2337.  
  2338.      These  functions are variations of SCRREST and SCRSAVE.  All of them allow
  2339.  
  2340. specification  of a page number, for color monitors.  They will save or restore
  2341.  
  2342. text  to a given page.  When used with monochrome monitors, the page specifica-
  2343.  
  2344. tion  should  always  be  zero.   SCRRESTPD and SCRSAVEPD write directly to the
  2345.  
  2346. screen  at  high  speed.   This  will cause "snow" if you have an old or poorly
  2347.  
  2348. designed  color  display  adapter  and  are  writing to the active screen page.
  2349.  
  2350. Under those conditions, you should use SCRRESTP/SCRSAVEP or SCRREST/SCRSAVE.
  2351.  
  2352.  
  2353. Example:
  2354.  
  2355.      WHERE = VARPTR(SCR(1)) : SCRNPAGE = 0
  2356.  
  2357.      CALL SCRRESTP(WHERE,SCRNPAGE) : LOCATE OLDROW,OLDCOL
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371. Name: SETCOMM
  2372.  
  2373.  
  2374. Type: Miscellaneous / CLONE
  2375.  
  2376.  
  2377. Description:
  2378.  
  2379.      Sets  communications  parameters on an opened communications device.  This
  2380.  
  2381. allows  you  to set  the  baud  rate  higher than BASIC normally allows, and to
  2382.  
  2383. change the comm parameters without having to close the comm device.
  2384.  
  2385.      Note  that  BASIC  currently limits access to comm ports one and two.  You
  2386.  
  2387. can  set parms on ports 1-4 using SETCOMM, however.  Hopefully a future release
  2388.  
  2389. of ADVBAS will allow you to use the other two ports if you have them.
  2390.  
  2391.      Why  is  it  bad to have to close the comm device?  Because that will make
  2392.  
  2393. the  DTR  signal  drop,  which  will  cause many modems to drop the carrier and
  2394.  
  2395. lose  your  connection.   In  fact,  for  Hayes-type modems, that's a much more
  2396.  
  2397. reliable way to end communications than using the ATH modem command.
  2398.  
  2399.      If  you  try to set a comm port which does not exist, the port number will
  2400.  
  2401. be  set  to  zero  after  the  call.  If you give illegal parameters elsewhere,
  2402.  
  2403. the  port  will  be set to a default of 300 baud, Even parity, Seven-bit words,
  2404.  
  2405. and One stop bit (any of the parms which were legal will be used).
  2406.  
  2407.  
  2408. Example:
  2409.  
  2410.      OPEN"R",1,"COM1:300,E,7,1,RS,CS,DS"
  2411.  
  2412.      COMMPORT = 1 : BPS = 6 : PARITY = 0 : WORDLENGTH = 8 : STOPBITS = 1
  2413.  
  2414.      CALL SETCOMM(COMMPORT,BPS,PARITY,WORDLENGTH,STOPBITS)
  2415.  
  2416.      REM sets the port to 19200 baud, No parity, 8 bit words, 1 stop bit.
  2417.  
  2418.  
  2419. Settings:
  2420.  
  2421.      COMMPORT  may  be  1  - 2, and will be returned as 0 if the specified port
  2422.  
  2423. doesn't exist.  Four ports are allowed, but you can only access 1 and 2.
  2424.  
  2425.      BPS  ("baud  rate")  is  specified  by a number from 0 - 7.  Use 0 for 300
  2426.  
  2427. bps,  1  for  600, 2 for 1200, 3 for 2400, 4 for 4800, 5 for 9600, 6 for 19200,
  2428.  
  2429. and  7  for  38400 bps.  Whether you can actually get higher speeds will depend
  2430.  
  2431. on the quality of your communications port.
  2432.  
  2433.      PARITY is a number 0-2.  Use 0 for None, 1 for Odd, and 2 for Even.
  2434.  
  2435.      WORDLENGTH is 7 or 8, and STOPBITS is 1 or 2, just as you'd expect.
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441. Name: SETDRV
  2442.  
  2443.  
  2444. Type: Disk / DOS
  2445.  
  2446.  
  2447. Description:
  2448.  
  2449.      Sets  the  default drive.  The drive string must be at least one character
  2450.  
  2451. long, and start with a letter specifying a disk drive.
  2452.  
  2453.  
  2454. Example:
  2455.  
  2456.      DRV$="B:"
  2457.  
  2458.           .
  2459.  
  2460.           .
  2461.  
  2462.      CALL SETDRV(DRV$)
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478. Name: SETFATTR
  2479.  
  2480.  
  2481. Type: Disk / DOS
  2482.  
  2483.  
  2484. Description:
  2485.  
  2486.      Sets  file  attribute.   See section on file attributes at the end of this
  2487.  
  2488. manual.
  2489.  
  2490.  
  2491. Example:
  2492.  
  2493.      FIL$ = FIL$ + CHR$(0): CALL SETFATTR(FIL$,ATTR)
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499. Name: SETFTD
  2500.  
  2501.  
  2502. Type: Disk / DOS
  2503.  
  2504.  
  2505. Description:
  2506.  
  2507.      Sets  file  time/date  stamp.   The filename must be terminated with a NUL
  2508.  
  2509. character.   The  year  may  be  either a four digit or two digit number (e.g.,
  2510.  
  2511. may  be  either  1986 or just 86).  DOS will round the seconds value off to the
  2512.  
  2513. next  lower  even  number.   If there is a problem with the filename, the month
  2514.  
  2515. will be returned as -1.
  2516.  
  2517.  
  2518. Example:
  2519.  
  2520.      FIL$=FIL$+CHR$(0)
  2521.  
  2522.      CALL SETFTD(FIL$,MONTH,DAY,YEAR,HOUR,MINUTE,SECOND)
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562. Name: SETMATI
  2563.  
  2564.  
  2565. Type: Miscellaneous / ANY
  2566.  
  2567.  
  2568. Description:
  2569.  
  2570.      Sets the first SIZ elements of an integer array to a given (scalar) value,
  2571.  
  2572. INITVAL.   It will work on multi-dimensional arrays, in which case the leftmost
  2573.  
  2574. dimension increments first.  See examples for clarification.
  2575.  
  2576.  
  2577. Example:
  2578.  
  2579.      OPTION BASE 0: DEFINT A-Z: DIM BANANA(9)
  2580.  
  2581.      SIZ=10: INITVAL=-3: ARLOC=VARPTR(BANANA(0))
  2582.  
  2583.      CALL SETMATI(ARLOC,SIZ,INITVAL)
  2584.  
  2585.      REM  we have just initialized all 10 elements of the array to
  2586.  
  2587.      REM  the value -3.
  2588.  
  2589.  
  2590. Example:
  2591.  
  2592.      OPTION BASE 1: DEFINT A-Z: DIM FOO(3,5)
  2593.  
  2594.      SIZ=5: INITVAL=20000: ARLOC=VARPTR(FOO(1,1))
  2595.  
  2596.      CALL SETMATI(ARLOC,SIZ,INITVAL)
  2597.  
  2598.      REM  we have just set the first five elements of the array to
  2599.  
  2600.      REM  20000.  The first five elements are FOO(1,1), FOO(2,1),
  2601.  
  2602.      REM  FOO(3,1), FOO(1,2), FOO(2,2).  If you wanted to initialize
  2603.  
  2604.      REM  the whole array to 20000, you'd set SIZ=3*5 for OPTION BASE 1,
  2605.  
  2606.      REM  or SIZ=(3+1)*(5+1) for OPTION BASE 0, in this case...
  2607.  
  2608.      REM  By changing the first element (in the ARLOC assignment), you
  2609.  
  2610.      REM  can set any part of the array, not just the first elements.
  2611.  
  2612.      REM  See SCRSAVE/SCRREST if you need to clear up that last point.
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618. Name: SETSUB
  2619.  
  2620.  
  2621. Type: Disk / DOS
  2622.  
  2623.  
  2624. Description:
  2625.  
  2626.      Sets  the  default subdirectory.  The subdirectory string must be at least
  2627.  
  2628. one  character  in  length,  since  it  must  be terminated by a NUL character.
  2629.  
  2630. A  negative  one  will  be returned if there was a problem setting to the given
  2631.  
  2632. subdirectory  (either  it's  not available on the default drive, or a bad name,
  2633.  
  2634. most likely); else zero will be returned if all went well.
  2635.  
  2636.  
  2637. Example:
  2638.  
  2639.      TMP$ = SUB$+CHR$(0): CALL SETSUB(TMP$,ERCD) :
  2640.  
  2641.      IF ERCD THEN bad subdir ELSE new default subdir selected
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663. Name: SOUNDEX
  2664.  
  2665.  
  2666. Type: String / ANY
  2667.  
  2668.  
  2669. Description:
  2670.  
  2671.      This  routine  returns  the  Soundex  code  for a string you give it.  I'm
  2672.  
  2673. not  sure  who  invented  Soundex,  but it's pretty handy.  The Soundex routine
  2674.  
  2675. takes  a  word  and returns a string which represents what the word sounds like
  2676.  
  2677. in  an  abstract  format.  Similar-sounding words can thus be identified easily
  2678.  
  2679. by  your  program after Soundex processing.  This can be useful in applications
  2680.  
  2681. where  a  person  is  not  sure of the exact spelling of a word/name/city, etc.
  2682.  
  2683. To  use,  put  the  word  in  WORD$, initialize the return string SCODE$ to the
  2684.  
  2685. same  length  as  WORD$, and execute the routine.  SLEN% will return the actual
  2686.  
  2687. length  of  SCODE$, which may vary from zero to the length of WORD$.  If SCODE$
  2688.  
  2689. is  not  as  long  as  WORD$ when the routine is called, SLEN% will be returned
  2690.  
  2691. as  -1  to  flag  an error.  The Soundex code is returned as a series of digits
  2692.  
  2693. in SCODE$, although you can represent this any way you choose in your program.
  2694.  
  2695.  
  2696. Example:
  2697.  
  2698.      WORD$ = "AnyWord": SCODE$=WORD$: CALL SOUNDEX(WORD$,SCODE$,SLEN)
  2699.  
  2700.      PRINT"The Soundex code for ";WORD$;" is ";LEFT$(SCODE$,SLEN);"."
  2701.  
  2702.      REM  Try this routine a few times to get a feel for it.
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708. Name: STRIP
  2709.  
  2710.  
  2711. Type: String / ANY
  2712.  
  2713.  
  2714. Description:
  2715.  
  2716.      Strips  all  occurrences  of  a given target character from a given source
  2717.  
  2718. string.   The  source  string  may  be any length; the target string must be at
  2719.  
  2720. least  one  character.   The  new  length of the source string will be returned
  2721.  
  2722. as an integer, since external routines may not change the length of BASIC
  2723.  
  2724. strings directly.
  2725.  
  2726.  
  2727. Example:
  2728.  
  2729.      MSG$="12 - 2 =   10"
  2730.  
  2731.           .
  2732.  
  2733.           .
  2734.  
  2735.      CH$=" ": CALL STRIP(MSG$,CH$,MLEN): MSG$ = LEFT$(MSG$,MLEN)
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761. Name: STRIPRANGE
  2762.  
  2763.  
  2764. Type: String / ANY
  2765.  
  2766.  
  2767. Description:
  2768.  
  2769.      Strips  all  characters  within a given range out of a source string.  The
  2770.  
  2771. source  string  may  be  any  length.  The new length of the source string will
  2772.  
  2773. be returned as an integer.
  2774.  
  2775.  
  2776. Example:
  2777.  
  2778.      MSG$="ALL uppercase letters will be G-O-N-E gone"
  2779.  
  2780.      LO = ASC("A"): HI = ASC("Z")
  2781.  
  2782.      CALL STRIPRANGE(MSG$,LO,HI,MLEN): PRINT LEFT$(MSG$,MLEN)
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788. Name: UPCASE
  2789.  
  2790.  
  2791. Type: String / ANY
  2792.  
  2793.  
  2794. Description:
  2795.  
  2796.      Converts  a  string  to  all  uppercase.  Leaves non-alphabetic characters
  2797.  
  2798. untouched.  String may be any length.
  2799.  
  2800.  
  2801. Example:
  2802.  
  2803.      MSG$="Four score and seven years ago"
  2804.  
  2805.                .
  2806.  
  2807.                .
  2808.  
  2809.      CALL UPCASE(MSG$)
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847. Name: WEEKDAY
  2848.  
  2849.  
  2850. Type: Miscellaneous / DOS
  2851.  
  2852.  
  2853. Description:
  2854.  
  2855.      Returns  an  integer  from  1  -  7 indicating the day of the week, Sunday
  2856.  
  2857. through Saturday.  The example routine turns this integer into the week day.
  2858.  
  2859.  
  2860. Example:
  2861.  
  2862.      CALL WEEKDAY(DAY%): DLEN% = VAL(MID$("3346535",DAY,1))
  2863.  
  2864.      DLOC% = ASC(MID$("ADGKQVY",DAY%)): REM  This string MUST be uppercase!
  2865.  
  2866.      PRINT"Today is ";MID$("SunMonTuesWednesThursFriSatur",DLOC%,DLEN%);"day."
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872. Name: WRITEBITF
  2873.  
  2874.  
  2875. Type: Miscellaneous / ANY
  2876.  
  2877.  
  2878. Description:
  2879.  
  2880.      Allows  a  value  to be written into a given location of a simulated array
  2881.  
  2882. of  words  of  arbitrary  bit  length  (1-8 bits per word).  This goes with the
  2883.  
  2884. READBITF  function  above.   The "BITF" is for Bit Field, because the functions
  2885.  
  2886. work  by  creating  fields  of  arbitrary bit length within what is actually an
  2887.  
  2888. integer array.
  2889.  
  2890.  
  2891. Example:
  2892.  
  2893.      CALL WRITEBITF(ARRAYLOC,INDEX,BITFSIZE,VALUE)
  2894.  
  2895.      REM  See the READBITF function, and check out the BITFTEST.BAS if you
  2896.  
  2897.      REM  have the ADVBAS contributor disk, to better idea of what these
  2898.  
  2899.      REM  functions do.  This function is not for novice programmers!
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.  
  2915.  
  2916.  
  2917.  
  2918.  
  2919.  
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935. Name: XLATE
  2936.  
  2937.  
  2938. Type: String / ANY
  2939.  
  2940.  
  2941. Description:
  2942.  
  2943.      This  function  translates a string, character by character, using a table
  2944.  
  2945. you  supply.   The  character's  ASCII value is used as the index to the table,
  2946.  
  2947. and  the  value  at  that location replaces the character's current value.  The
  2948.  
  2949. character  may  be  one  byte  in  length, in which case it will be translated,
  2950.  
  2951. or  zero  bytes,  in  which  case  nothing will happen.  The translation string
  2952.  
  2953. must  be  256  bytes  long  (remember,  strings may be longer than 255 bytes in
  2954.  
  2955. Compiled BASIC, so this is ok).
  2956.  
  2957.  
  2958. Example:
  2959.  
  2960.     XLT$ = "": FOR X=0 TO 255: XLT$=XLT$+CHR$(X): NEXT
  2961.  
  2962.     MID$(XLT$,1,5) = "ABCDE": CH$ = CHR$(0)
  2963.  
  2964.     CALL XLATE$(CH$,XLT$): PRINT CH$
  2965.  
  2966.     REM  CH$ ends up "A", since the start of the table + zero bytes
  2967.  
  2968.     REM      contains "A".  We add zero bytes, because CH$ was
  2969.  
  2970.     REM      originally equal to CHR$(0).
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976. Name: XMPRINT
  2977.  
  2978.  
  2979. Type: Video / BIOS
  2980.  
  2981.  
  2982. Description:
  2983.  
  2984.      This  routine  combines the XLATE and MPRINTC functions.  It takes a char-
  2985.  
  2986. acter,  runs it through a translation table, and prints it to the screen unless
  2987.  
  2988. the  translated  value  is  NUL  (ASCII  zero).  If it's NUL, no printing takes
  2989.  
  2990. place.   MS-DOS  calls  are  used for printing, so ANSI.SYS will work.  See the
  2991.  
  2992. XLATE and MPRINTC routines for further information.
  2993.  
  2994.  
  2995. Example:
  2996.  
  2997.      CALL XMPRINT(CH$,XLATE$,COL,ROW): LOCATE ROW,COL
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028. Name: XQPRINT
  3029.  
  3030.  
  3031. Type: Video / CLONE
  3032.  
  3033.  
  3034. Description:
  3035.  
  3036.      This  function  is  an  extended  version of QPRINT.  It is more flexible,
  3037.  
  3038. and  only  a  trifle slower.  XQPRINT has two advantages over QPRINT: it allows
  3039.  
  3040. you  to  choose  a  color/attribute  to use, and lets you choose a display page
  3041.  
  3042. (color/graphics  adapters  only!).   The  attribute  ATTR  must be set up using
  3043.  
  3044. a  special  formula,  and  the display page is limited to a range of 0-3.  This
  3045.  
  3046. means  that  in  40-column  mode,  the display page used will actually be twice
  3047.  
  3048. the  argument  you  give  the  function, giving you access to 40-column display
  3049.  
  3050. pages  0,2,4,  and  6.   Or  so  the theory goes.  The page argument is ignored
  3051.  
  3052. for monochrome adapters.
  3053.  
  3054.  
  3055. Example:
  3056.  
  3057.      ST$ = "This is a test of fast screen printing"
  3058.  
  3059.      ROW = 10: COL = 20: PAGE = 0
  3060.  
  3061.      ATTR = (BACKGROUNDCOLOR AND 7) * 16 + FOREGROUNDCOLOR
  3062.  
  3063.      CALL XQPRINT(ST$,ROW,COL,ATTR,PAGE)
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069. Name: XQPRINTD
  3070.  
  3071.  
  3072. Type: Video / CLONE
  3073.  
  3074.  
  3075. Description:
  3076.  
  3077.      This  function  is  identical  to  XQPRINT, with the one exception that it
  3078.  
  3079. writes directly to the screen.  That makes it even faster than XQPRINT, but
  3080.  
  3081. means  that  it  will  cause  snow  on some color monitors when printing to the
  3082.  
  3083. active display page.
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.                                 File Attributes
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.      Every  file  has an "attribute byte" which tells something about the file.
  3125.  
  3126. This  can  be  modified  to  some  extent.   For instance, any file can be made
  3127.  
  3128. "hidden",  in  which  case  it will be invisible; this includes subdirectories,
  3129.  
  3130. which  can  still be used even if you can't see that they're there.  Some kinds
  3131.  
  3132. of  changes  are  not  possible,  however: you can't change a subdirectory into
  3133.  
  3134. a normal file, for example.
  3135.  
  3136.  
  3137.  
  3138. Attribute      Code      Description
  3139.  
  3140.  
  3141. Normal         00h       A normal file.
  3142.  
  3143. Read-only      01h       File can be renamed, but not killed or modified.
  3144.  
  3145. Hidden         02h       File disappears from directory, can't be opened.
  3146.  
  3147. System         04h       Like HIDDEN.  Used for system (DOS, BIOS) files.
  3148.  
  3149. Volume-ID      08h       A disk's volume id.  Can only be one, in root dir.
  3150.  
  3151. Directory      10h       Subdirectory.  Can't be changed to another attribute.
  3152.  
  3153. Archive        20h       Usually set.  Sometimes used for hard disk backup.
  3154.  
  3155.  
  3156.  
  3157.      Combinations  of the codes are possible, as I've mentioned.  For instance,
  3158.  
  3159. a  hidden  subdirectory  would  have  a code of 12h.  A normal file, because of
  3160.  
  3161. the  archive  bit,  might show up as either 00h or 20h... and so on.  Note this
  3162.  
  3163. is  all  in  hexadecimal,  hence  the  "h" postfix.  Convert to decimal form as
  3164.  
  3165. necessary  when  calling  routines  which  use  the  file attribute.  BASIC has
  3166.  
  3167. functions  to  handle  this  for you if you don't understand hex-- see the HEX$
  3168.  
  3169. function and &H prefix in your BASIC manual.
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.                                   BASCOM Bugs
  3207.  
  3208.                           (info unrelated to ADVBAS!)
  3209.  
  3210.  
  3211.  
  3212.  
  3213.      Following  are  a  few  notes  on  BASIC Compiler bugs that I've run into.
  3214.  
  3215. These  are  not  caused  by  the ADVBAS routines, and have no relation to them.
  3216.  
  3217. I  just  thought  it might be helpful if I mentioned them, since anyone reading
  3218.  
  3219. this evidently has, or is considering buying, a BASIC Compiler.
  3220.  
  3221.  
  3222. IBM BASIC Compiler v1.00 (may well not apply to the current version 2):
  3223.  
  3224.  
  3225.      Illegal  file  names  return  a  "Bad  file number" error, rather than the
  3226.  
  3227. expected "Bad file name".
  3228.  
  3229.  
  3230.      The  control  codes  to  move the cursor left and right work fine, but not
  3231.  
  3232. the ones to move it up and down, which do nothing.
  3233.  
  3234.  
  3235.      Register  BP  is not saved by the compiler when it does a CALL.  This must
  3236.  
  3237. be  done  by  the  called  routine, since this register is used by the compiler
  3238.  
  3239. for vital information.
  3240.  
  3241.  
  3242.      The  /E compiler option seems to introduce errors into some programs which
  3243.  
  3244. crash  them  by freezing the computer or giving a "String Space Corrupt" error.
  3245.  
  3246. If  this  happens,  I've found you can fix it by adding the /D option, or using
  3247.  
  3248. /X  instead  of  /E.   The latter method cuts down heavily on available program
  3249.  
  3250. space,  so  it  may  not  be as good as the former.  Both add a fair bit to the
  3251.  
  3252. EXE  program  size.   It's a hard life...  This problem may also cause programs
  3253.  
  3254. compiled  without  the  /O  option to lock up, which can't be fixed by using /X
  3255.  
  3256. or /D.  Use the /O option if this happens.
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.                                   BASCOM Bugs
  3295.  
  3296.  
  3297.  
  3298.  
  3299. Microsoft QuickBASIC Compiler v1.00:
  3300.  
  3301.  
  3302.      If  there  is not enough memory when you try to execute the SHELL command,
  3303.  
  3304. your  program  will crash.  There is no way to avoid this using error trapping,
  3305.  
  3306. because  the  memory  reallocation  will  have fried the stack.  So even if you
  3307.  
  3308. trap  the  OUT  OF MEMORY error, you'll still crash with a RETURN WITHOUT GOSUB
  3309.  
  3310. if  you  try  to return from a subroutine, or a STRING SPACE CORRUPT error when
  3311.  
  3312. the  compiler  gets  around  to  doing  a string garbage collection.  Bad news.
  3313.  
  3314. It would be nice if it tried to check to see if there was enough memory first.
  3315.  
  3316.  
  3317.      The error STRING FORMULA TOO COMPLEX appears erratically in some programs,
  3318.  
  3319. even  with  the  simplest possible string formulae (like V$="TEST").  This only
  3320.  
  3321. seems  to  happen  in  programs  which  do  a lot of string manipulation, which
  3322.  
  3323. suggests  that  the compiler has a flaky and is doing something wrong with gar-
  3324.  
  3325. bage  collection,  or  something  like  that.   There seems to be no way to get
  3326.  
  3327. around  this bug either-- also bad news.  If you have this problem, I recommend
  3328.  
  3329. that you complain vociferously to Microsoft!
  3330.  
  3331.  
  3332.  
  3333. Microsoft QuickBASIC Compiler v1.02:
  3334.  
  3335.  
  3336.      I  haven't  had a chance to test it out much yet, but they claim that this
  3337.  
  3338. release  solves  the  SHELL  crash  problem.  Also, more control characters are
  3339.  
  3340. now  printed  out  just  like  BASICA.   Many  miscellaneous problems have been
  3341.  
  3342. fixed...
  3343.           But not the infamous STRING FORMULA TOO COMPLEX error.  Sigh.
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.  
  3374.  
  3375.  
  3376.  
  3377.  
  3378.  
  3379.  
  3380.  
  3381.  
  3382.                                   BASCOM Bugs
  3383.  
  3384.  
  3385.  
  3386.  
  3387. Microsoft QuickBASIC Compiler v2.00:
  3388.  
  3389.  
  3390.      Well,  this  release  fixes  yet  more  compiler bugs.  The STRING FORMULA
  3391.  
  3392. TOO  COMPLEX  error  lives  on,  however.  I'm going to have to track that down
  3393.  
  3394. and  send  in  an  example program to Microsoft, I guess, as soon as I can find
  3395.  
  3396. the  time.   A few new functions have been added, but nothing particularly use-
  3397.  
  3398. ful.   The  new  programming environment (a la Turbo Pascal) is poorly designed
  3399.  
  3400. for  an  environment  which is evidently supposed to mimic the "intuitive" feel
  3401.  
  3402. of  the MacIntosh.  The editor really isn't adequate, and suffers from a number
  3403.  
  3404. of  irritating  bugs.   The  compiler  is now a massive 180K, and takes forever
  3405.  
  3406. to  load.   The "user library" feature is fairly worthless-- you can only build
  3407.  
  3408. libraries  of  BASIC  subprograms  with it, not assembly code; you are required
  3409.  
  3410. to  list  all the names of all the subprograms in a library whenever you modify
  3411.  
  3412. the  library;  and  the user library is in its own unique format, so if you had
  3413.  
  3414. hoped  to  be  able  to link it with other languages, forget it.  The one thing
  3415.  
  3416. that  is  good  about  the  new version of the compiler is the manual, which is
  3417.  
  3418. really excellent-- enormous, clear and detailed.
  3419.  
  3420.  
  3421.      Screen  paging  is  doesn't  work.   Assembly routines (like ADVBAS) can't
  3422.  
  3423. be  used  in  the  normal  mode (they generate "UNRESOLVED SUBPROGRAM" errors).
  3424.  
  3425. See  the  notes  at  the  beginning of this document for how to get around that
  3426.  
  3427. problem.   The  editor  has a defective search-and-replace function, adds blank
  3428.  
  3429. lines  at  the  end  of the program under certain conditions, and allows you to
  3430.  
  3431. put some control characters directly into the program (which gives the compiler
  3432.  
  3433. odd  problems).   When  entering  the filename, you have to use Shift-Backspace
  3434.  
  3435. instead of the Delete key to delete characters.  The use of TAB, SPACE, RETURN,
  3436.  
  3437. and  the  arrow  keys  when  making  a choice on the menus is arbitrary, weird,
  3438.  
  3439. and  counterintuitive  in the extreme.  If you use the old method of compiling,
  3440.  
  3441. bypassing  the  new  environment,  you  no  longer get any error messages, just
  3442.  
  3443. an error count.  You can't get a source listing any more, either.
  3444.  
  3445.  
  3446.  
  3447.  
  3448. Wish list for QuickBASIC:
  3449.  
  3450.  
  3451.      Recursive functions.
  3452.  
  3453.      No bugs!
  3454.  
  3455.      Production of code which can be linked with other languages.
  3456.  
  3457.      A  smaller  compiler  (take  out  the  new environment and editor, please,
  3458.  
  3459. and put the error messages back!).
  3460.  
  3461.      An  error  trapping  function  that returns the label of the routine where
  3462.  
  3463. the error took place (like ERL, only for labels).
  3464.  
  3465.      Communications  functions  which  don't  produce  errors  whenever you get
  3466.  
  3467. the slightest bit of line noise.
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.                                   BASIC Bugs
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.      This  is  a  peculiar  one... it  seems that BASIC can create files having
  3494.  
  3495. names  which  contain  blank  spaces.  This is a problem, because DOS considers
  3496.  
  3497. the  space  to  be a delimiter, and thus cannot handle these files.  Such files
  3498.  
  3499. will not be listed correctly in the directory, and will be impossible to manipu-
  3500.  
  3501. late  from  DOS  (can't  read,  delete,  or otherwise handle the file).  So, be
  3502.  
  3503. careful  to  screen  out  spaces  when  creating files from BASIC!  This caveat
  3504.  
  3505. also  applies  to  subdirectories,  including  those  created  with the MAKESUB
  3506.  
  3507. routine of ADVBAS.
  3508.  
  3509.  
  3510.  
  3511.  
  3512. Call for help:
  3513.  
  3514.  
  3515.      If  you  find  any  other  bugs in any IBM/Microsoft BASIC compiler, or in
  3516.  
  3517. ADVBAS  for  that  matter,  please  let me know.  If I can't fix it, at least I
  3518.  
  3519. can warn people!
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.  
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.